home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume21 / berkeley_yacc / part01 next >
Encoding:
Internet Message Format  |  1990-04-05  |  59.1 KB

  1. Subject:  v21i078:  Public domain Berkeley YACC, Part01/05
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: d38b87aa e111aeb6 1c58fd13 e4e2d40c
  5.  
  6. Submitted-by: Robert Corbett <corbett@ernie.berkeley.edu>
  7. Posting-number: Volume 21, Issue 78
  8. Archive-name: berkeley_yacc/part01
  9.  
  10.     Berkeley Yacc is an LALR(1) parser generator.  Berkeley Yacc has been made
  11. as compatible as possible with AT&T Yacc.  Berkeley Yacc can accept any input
  12. specification that conforms to the AT&T Yacc documentation.  Specifications
  13. that take advantage of undocumented features of AT&T Yacc will probably be
  14. rejected.
  15.  
  16.     Berkeley Yacc is distributed with no warranty whatever.  The code is certain
  17. to contain errors.  Neither the author nor any contributor takes responsibility
  18. for any consequences of its use.
  19.  
  20.     Berkeley Yacc is in the public domain.  The data structures and algorithms
  21. used in Berkeley Yacc are all either taken from documents available to the
  22. general public or are inventions of the author.  Anyone may freely distribute
  23. source or binary forms of Berkeley Yacc whether unchanged or modified.
  24. Distributers may charge whatever fees they can obtain for Berkeley Yacc.
  25. Programs generated by Berkeley Yacc may be distributed freely.
  26.  
  27.     Bugs may be reported to
  28.  
  29.               corbett@berkeley.edu
  30.  
  31. Do not expect rapid responses.
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then unpack
  34. # it by saving it into a file and typing "sh file".  To overwrite existing
  35. # files, type "sh file -c".  You can also feed this as standard input via
  36. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  37. # will see the following message at the end:
  38. #        "End of archive 1 (of 5)."
  39. # Contents:  ACKNOWLEDGEMENTS MANIFEST Makefile NEW_FEATURES
  40. #   NO_WARRANTY README closure.c defs.h error.c main.c manpage
  41. #   symtab.c test test/error.output test/error.tab.c test/error.tab.h
  42. #   test/error.y test/ftp.tab.h verbose.c warshall.c
  43. # Wrapped by rsalz@litchi.bbn.com on Mon Apr  2 11:43:41 1990
  44. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  45. if test -f 'ACKNOWLEDGEMENTS' -a "${1}" != "-c" ; then 
  46.   echo shar: Will not clobber existing file \"'ACKNOWLEDGEMENTS'\"
  47. else
  48. echo shar: Extracting \"'ACKNOWLEDGEMENTS'\" \(750 characters\)
  49. sed "s/^X//" >'ACKNOWLEDGEMENTS' <<'END_OF_FILE'
  50. X     Berkeley Yacc owes much to the unflagging efforts of Keith Bostic.
  51. XHis badgering kept me working on it long after I was ready to quit.
  52. X
  53. X     Berkeley Yacc is based on the excellent algorithm for computing LALR(1)
  54. Xlookaheads developed by Tom Pennello and Frank DeRemer.  The algorithm is
  55. Xdescribed in their almost impenetrable article in TOPLAS 4,4.
  56. X
  57. X     Finally, much of the credit for the latest version must go to those
  58. Xwho pointed out deficiencies of my earlier releases.  Among the most
  59. Xprolific contributors were
  60. X
  61. X      Benson I. Margulies
  62. X      Dave Gentzel
  63. X      Peter S. Housel
  64. X      Dale Smith
  65. X      Ozan Yigit
  66. X      John Campbell
  67. X      Bill Sommerfeld
  68. X      Paul Hilfinger
  69. X      Gary Bridgewater
  70. X      Dave Bakken
  71. X      Dan Lanciani
  72. X      Richard Sargent
  73. X      Parag Patel
  74. END_OF_FILE
  75. if test 750 -ne `wc -c <'ACKNOWLEDGEMENTS'`; then
  76.     echo shar: \"'ACKNOWLEDGEMENTS'\" unpacked with wrong size!
  77. fi
  78. # end of 'ACKNOWLEDGEMENTS'
  79. fi
  80. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  81.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  82. else
  83. echo shar: Extracting \"'MANIFEST'\" \(995 characters\)
  84. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  85. X   File Name        Archive #    Description
  86. X-----------------------------------------------------------
  87. X ACKNOWLEDGEMENTS           1    
  88. X MANIFEST                   1    
  89. X Makefile                   1    
  90. X NEW_FEATURES               1    
  91. X NO_WARRANTY                1    
  92. X README                     1    
  93. X closure.c                  1    
  94. X defs.h                     1    
  95. X error.c                    1    
  96. X lalr.c                     2    
  97. X lr0.c                      2    
  98. X main.c                     1    
  99. X manpage                    1    
  100. X mkpar.c                    2    
  101. X output.c                   3    
  102. X reader.c                   4    
  103. X skeleton.c                 2    
  104. X symtab.c                   1    
  105. X test                       1    
  106. X test/error.output          1    
  107. X test/error.tab.c           1    
  108. X test/error.tab.h           1    
  109. X test/error.y               1    
  110. X test/ftp.output            3    
  111. X test/ftp.tab.c             5    
  112. X test/ftp.tab.h             1    
  113. X test/ftp.y                 4    
  114. X verbose.c                  1    
  115. X warshall.c                 1    
  116. END_OF_FILE
  117. if test 995 -ne `wc -c <'MANIFEST'`; then
  118.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  119. fi
  120. # end of 'MANIFEST'
  121. fi
  122. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  123.   echo shar: Will not clobber existing file \"'Makefile'\"
  124. else
  125. echo shar: Extracting \"'Makefile'\" \(1365 characters\)
  126. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  127. XDEST          = .
  128. X
  129. XHDRS          = defs.h
  130. X
  131. XCFLAGS          = -O
  132. X
  133. XLDFLAGS          =
  134. X
  135. XLIBS          =
  136. X
  137. XLINKER          = cc
  138. X
  139. XMAKEFILE      = Makefile
  140. X
  141. XOBJS          = closure.o \
  142. X        error.o \
  143. X        lalr.o \
  144. X        lr0.o \
  145. X        main.o \
  146. X        mkpar.o \
  147. X        output.o \
  148. X        reader.o \
  149. X        skeleton.o \
  150. X        symtab.o \
  151. X        verbose.o \
  152. X        warshall.o
  153. X
  154. XPRINT          = pr -f -l88
  155. X
  156. XPROGRAM          = yacc
  157. X
  158. XSRCS          = closure.c \
  159. X        error.c \
  160. X        lalr.c \
  161. X        lr0.c \
  162. X        main.c \
  163. X        mkpar.c \
  164. X        output.c \
  165. X        reader.c \
  166. X        skeleton.c \
  167. X        symtab.c \
  168. X        verbose.c \
  169. X        warshall.c
  170. X
  171. Xall:        $(PROGRAM)
  172. X
  173. X$(PROGRAM):     $(OBJS) $(LIBS)
  174. X        @echo -n "Loading $(PROGRAM) ... "
  175. X        @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
  176. X        @echo "done"
  177. X
  178. Xclean:;        @rm -f $(OBJS)
  179. X
  180. Xdepend:;    @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
  181. X
  182. Xindex:;        @ctags -wx $(HDRS) $(SRCS)
  183. X
  184. Xinstall:    $(PROGRAM)
  185. X        @echo Installing $(PROGRAM) in $(DEST)
  186. X        @install -s $(PROGRAM) $(DEST)
  187. X
  188. Xlisting:;    @$(PRINT) Makefile $(HDRS) $(SRCS) | lpr
  189. X
  190. Xlint:;        @lint $(SRCS)
  191. X
  192. Xprogram:        $(PROGRAM)
  193. X
  194. Xtags:           $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
  195. X
  196. Xupdate:        $(DEST)/$(PROGRAM)
  197. X
  198. X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS)
  199. X        @make -f $(MAKEFILE) DEST=$(DEST) install
  200. X###
  201. Xclosure.o: defs.h
  202. Xerror.o: defs.h
  203. Xlalr.o: defs.h
  204. Xlr0.c: defs.h
  205. Xmain.o: defs.h
  206. Xmkpar.o: defs.h
  207. Xoutput.o: defs.h
  208. Xreader.o: defs.h
  209. Xskeleton.o: defs.h
  210. Xsymtab.o: defs.h
  211. Xverbose.o: defs.h
  212. Xwarshall.o: defs.h
  213. END_OF_FILE
  214. if test 1365 -ne `wc -c <'Makefile'`; then
  215.     echo shar: \"'Makefile'\" unpacked with wrong size!
  216. fi
  217. # end of 'Makefile'
  218. fi
  219. if test -f 'NEW_FEATURES' -a "${1}" != "-c" ; then 
  220.   echo shar: Will not clobber existing file \"'NEW_FEATURES'\"
  221. else
  222. echo shar: Extracting \"'NEW_FEATURES'\" \(2541 characters\)
  223. sed "s/^X//" >'NEW_FEATURES' <<'END_OF_FILE'
  224. X     This version of Berkeley Yacc has been extensively reorganized and
  225. Xcontains many new features.  It is an amalgam of three earlier versions
  226. Xof Berkeley Yacc.  It is largely untested, so expect it to contain bugs.
  227. XWhen bugs are found report them to corbett@berkeley.edu.  Please
  228. Xinclude small examples if possible.
  229. X
  230. X     Despite my pleas not to be told of undocumented features of AT&T Yacc,
  231. XI have received unsolicited descriptions of such features.  Telling me of
  232. Xsuch features places the public-domain status of Berkeley Yacc at risk.
  233. XPlease do not send me descriptions of undocumented features.  On the
  234. Xother hand, I would be very interested in learning of documented
  235. Xfeatures I have not implemented.
  236. X
  237. X     The -l and -t options have been implemented.  The -l option tells
  238. XYacc not to include #line directives in the code it produces.  The -t
  239. Xoption causes debugging code to be included in the compiled parser.
  240. X
  241. X     The code for error recovery has been changed to implement the same
  242. Xalgorithm as AT&T Yacc.  There will still be differences in the way
  243. Xerror recovery works because AT&T Yacc uses more default reductions
  244. Xthan Berekeley Yacc.
  245. X
  246. X     The environment variable TMPDIR determines the directory where
  247. Xtemporary files will be created.  If TMPDIR is defined, temporary files
  248. Xwill be created in the directory whose pathname is the value of TMPDIR.
  249. XBy default, temporary files are created in /tmp.
  250. X
  251. X     The keywords are now case-insensitive.  For example, %nonassoc,
  252. X%NONASSOC, %NonAssoc, and %nOnAsSoC are all equivalent.
  253. X
  254. X     Commas and semicolons that are not part of C code are treated as
  255. Xcommentary.
  256. X
  257. X     Line-end comments, as in BCPL, are permitted.  Line-end comments
  258. Xbegin with // and end at the next end-of-line.  Line-end comments are
  259. Xpermitted in C code; they are converted to C comments on output.
  260. X
  261. X     The form of y.output files has been changed to look more like
  262. Xthose produced by AT&T Yacc.
  263. X
  264. X     A new kind of declaration has been added.  The form of the declaration
  265. Xis
  266. X
  267. X      %ident string
  268. X
  269. Xwhere string is a sequence of characters begining with a double quote
  270. Xand ending with either a double quote or the next end-of-line, whichever
  271. Xcomes first.  The declaration will cause a #ident directive to be written
  272. Xnear the start of the output file.
  273. X
  274. X     If a parser has been compiled with debugging code, that code can be
  275. Xenabled by setting an environment variable.  If the environment variable
  276. XYYDEBUG is set to 0, debugging output is suppressed.  If it is set to 1,
  277. Xdebugging output is written to standard output.
  278. END_OF_FILE
  279. if test 2541 -ne `wc -c <'NEW_FEATURES'`; then
  280.     echo shar: \"'NEW_FEATURES'\" unpacked with wrong size!
  281. fi
  282. # end of 'NEW_FEATURES'
  283. fi
  284. if test -f 'NO_WARRANTY' -a "${1}" != "-c" ; then 
  285.   echo shar: Will not clobber existing file \"'NO_WARRANTY'\"
  286. else
  287. echo shar: Extracting \"'NO_WARRANTY'\" \(156 characters\)
  288. sed "s/^X//" >'NO_WARRANTY' <<'END_OF_FILE'
  289. X     Berkeley Yacc is distributed with no warranty whatever.  The author
  290. Xand any other contributors take no responsibility for the consequences of
  291. Xits use.
  292. END_OF_FILE
  293. if test 156 -ne `wc -c <'NO_WARRANTY'`; then
  294.     echo shar: \"'NO_WARRANTY'\" unpacked with wrong size!
  295. fi
  296. # end of 'NO_WARRANTY'
  297. fi
  298. if test -f 'README' -a "${1}" != "-c" ; then 
  299.   echo shar: Will not clobber existing file \"'README'\"
  300. else
  301. echo shar: Extracting \"'README'\" \(1041 characters\)
  302. sed "s/^X//" >'README' <<'END_OF_FILE'
  303. X    Berkeley Yacc is an LALR(1) parser generator.  Berkeley Yacc has been made
  304. Xas compatible as possible with AT&T Yacc.  Berkeley Yacc can accept any input
  305. Xspecification that conforms to the AT&T Yacc documentation.  Specifications
  306. Xthat take advantage of undocumented features of AT&T Yacc will probably be
  307. Xrejected.
  308. X
  309. X    Berkeley Yacc is distributed with no warranty whatever.  The code is certain
  310. Xto contain errors.  Neither the author nor any contributor takes responsibility
  311. Xfor any consequences of its use.
  312. X
  313. X    Berkeley Yacc is in the public domain.  The data structures and algorithms
  314. Xused in Berkeley Yacc are all either taken from documents available to the
  315. Xgeneral public or are inventions of the author.  Anyone may freely distribute
  316. Xsource or binary forms of Berkeley Yacc whether unchanged or modified.
  317. XDistributers may charge whatever fees they can obtain for Berkeley Yacc.
  318. XPrograms generated by Berkeley Yacc may be distributed freely.
  319. X
  320. X    Bugs may be reported to
  321. X
  322. X              corbett@berkeley.edu
  323. X
  324. XDo not expect rapid responses.
  325. END_OF_FILE
  326. if test 1041 -ne `wc -c <'README'`; then
  327.     echo shar: \"'README'\" unpacked with wrong size!
  328. fi
  329. # end of 'README'
  330. fi
  331. if test -f 'closure.c' -a "${1}" != "-c" ; then 
  332.   echo shar: Will not clobber existing file \"'closure.c'\"
  333. else
  334. echo shar: Extracting \"'closure.c'\" \(4358 characters\)
  335. sed "s/^X//" >'closure.c' <<'END_OF_FILE'
  336. X#include "defs.h"
  337. X
  338. Xshort *itemset;
  339. Xshort *itemsetend;
  340. Xunsigned *ruleset;
  341. X
  342. Xstatic unsigned *first_derives;
  343. Xstatic unsigned *EFF;
  344. X
  345. X
  346. Xset_EFF()
  347. X{
  348. X    register unsigned *row;
  349. X    register int symbol;
  350. X    register short *sp;
  351. X    register int rowsize;
  352. X    register int i;
  353. X    register int rule;
  354. X
  355. X    rowsize = WORDSIZE(nvars);
  356. X    EFF = NEW2(nvars * rowsize, unsigned);
  357. X
  358. X    row = EFF;
  359. X    for (i = start_symbol; i < nsyms; i++)
  360. X    {
  361. X    sp = derives[i];
  362. X    for (rule = *sp; rule > 0; rule = *++sp)
  363. X    {
  364. X        symbol = ritem[rrhs[rule]];
  365. X        if (ISVAR(symbol))
  366. X        {
  367. X        symbol -= start_symbol;
  368. X        SETBIT(row, symbol);
  369. X        }
  370. X    }
  371. X    row += rowsize;
  372. X    }
  373. X
  374. X    reflexive_transitive_closure(EFF, nvars);
  375. X
  376. X#ifdef    DEBUG
  377. X    print_EFF();
  378. X#endif
  379. X}
  380. X
  381. X
  382. Xset_first_derives()
  383. X{
  384. X  register unsigned *rrow;
  385. X  register unsigned *vrow;
  386. X  register int j;
  387. X  register unsigned mask;
  388. X  register unsigned cword;
  389. X  register short *rp;
  390. X
  391. X  int rule;
  392. X  int i;
  393. X  int rulesetsize;
  394. X  int varsetsize;
  395. X
  396. X  rulesetsize = WORDSIZE(nrules);
  397. X  varsetsize = WORDSIZE(nvars);
  398. X  first_derives = NEW2(nvars * rulesetsize, unsigned) - ntokens * rulesetsize;
  399. X
  400. X  set_EFF();
  401. X
  402. X  rrow = first_derives + ntokens * rulesetsize;
  403. X  for (i = start_symbol; i < nsyms; i++)
  404. X    {
  405. X      vrow = EFF + ((i - ntokens) * varsetsize);
  406. X      cword = *vrow++;
  407. X      mask = 1;
  408. X      for (j = start_symbol; j < nsyms; j++)
  409. X    {
  410. X      if (cword & mask)
  411. X        {
  412. X          rp = derives[j];
  413. X          while ((rule = *rp++) >= 0)
  414. X        {
  415. X          SETBIT(rrow, rule);
  416. X        }
  417. X        }
  418. X
  419. X      mask <<= 1;
  420. X      if (mask == 0)
  421. X        {
  422. X          cword = *vrow++;
  423. X          mask = 1;
  424. X        }
  425. X    }
  426. X
  427. X      vrow += varsetsize;
  428. X      rrow += rulesetsize;
  429. X    }
  430. X
  431. X#ifdef    DEBUG
  432. X  print_first_derives();
  433. X#endif
  434. X
  435. X  FREE(EFF);
  436. X}
  437. X
  438. X
  439. Xclosure(nucleus, n)
  440. Xshort *nucleus;
  441. Xint n;
  442. X{
  443. X    register int ruleno;
  444. X    register unsigned word;
  445. X    register unsigned mask;
  446. X    register short *csp;
  447. X    register unsigned *dsp;
  448. X    register unsigned *rsp;
  449. X    register int rulesetsize;
  450. X
  451. X    short *csend;
  452. X    unsigned *rsend;
  453. X    int symbol;
  454. X    int itemno;
  455. X
  456. X    rulesetsize = WORDSIZE(nrules);
  457. X    rsp = ruleset;
  458. X    rsend = ruleset + rulesetsize;
  459. X    for (rsp = ruleset; rsp < rsend; rsp++)
  460. X    *rsp = 0;
  461. X
  462. X    csend = nucleus + n;
  463. X    for (csp = nucleus; csp < csend; ++csp)
  464. X    {
  465. X    symbol = ritem[*csp];
  466. X    if (ISVAR(symbol))
  467. X    {
  468. X        dsp = first_derives + symbol * rulesetsize;
  469. X        rsp = ruleset;
  470. X        while (rsp < rsend)
  471. X        *rsp++ |= *dsp++;
  472. X    }
  473. X    }
  474. X
  475. X    ruleno = 0;
  476. X    itemsetend = itemset;
  477. X    csp = nucleus;
  478. X    for (rsp = ruleset; rsp < rsend; ++rsp)
  479. X    {
  480. X    word = *rsp;
  481. X    if (word == 0)
  482. X        ruleno += BITS_PER_WORD;
  483. X    else
  484. X    {
  485. X        mask = 1;
  486. X        while (mask)
  487. X        {
  488. X        if (word & mask)
  489. X        {
  490. X            itemno = rrhs[ruleno];
  491. X            while (csp < csend && *csp < itemno)
  492. X            *itemsetend++ = *csp++;
  493. X            *itemsetend++ = itemno;
  494. X            while (csp < csend && *csp == itemno)
  495. X            ++csp;
  496. X        }
  497. X
  498. X            mask <<= 1;
  499. X            ++ruleno;
  500. X        }
  501. X    }
  502. X    }
  503. X
  504. X    while (csp < csend)
  505. X    *itemsetend++ = *csp++;
  506. X
  507. X#ifdef    DEBUG
  508. X  print_closure(n);
  509. X#endif
  510. X}
  511. X
  512. X
  513. X
  514. Xfinalize_closure()
  515. X{
  516. X  FREE(itemset);
  517. X  FREE(ruleset);
  518. X  FREE(first_derives + ntokens * WORDSIZE(nrules));
  519. X}
  520. X
  521. X
  522. X#ifdef    DEBUG
  523. X
  524. Xprint_closure(n)
  525. Xint n;
  526. X{
  527. X  register short *isp;
  528. X
  529. X  printf("\n\nn = %d\n\n", n);
  530. X  for (isp = itemset; isp < itemsetend; isp++)
  531. X    printf("   %d\n", *isp);
  532. X}
  533. X
  534. X
  535. Xprint_EFF()
  536. X{
  537. X    register int i, j, k;
  538. X    register unsigned *rowp;
  539. X    register unsigned word;
  540. X    register unsigned mask;
  541. X
  542. X    printf("\n\nEpsilon Free Firsts\n");
  543. X
  544. X    for (i = start_symbol; i < nsyms; i++)
  545. X    {
  546. X    printf("\n%s", symbol_name[i]);
  547. X    rowp = EFF + ((i - start_symbol) * WORDSIZE(nvars));
  548. X    word = *rowp++;
  549. X
  550. X    mask = 1;
  551. X    for (j = 0; j < nvars; j++)
  552. X    {
  553. X        if (word & mask)
  554. X        printf("  %s", symbol_name[start_symbol + j]);
  555. X
  556. X        mask <<= 1;
  557. X        if (mask == 0)
  558. X        {
  559. X        word = *rowp++;
  560. X        mask = 1;
  561. X        }
  562. X    }
  563. X    }
  564. X}
  565. X
  566. X
  567. Xprint_first_derives()
  568. X{
  569. X  register int i;
  570. X  register int j;
  571. X  register unsigned *rp;
  572. X  register unsigned cword;
  573. X  register unsigned mask;
  574. X
  575. X  printf("\n\n\nFirst Derives\n");
  576. X
  577. X  for (i = start_symbol; i < nsyms; i++)
  578. X    {
  579. X      printf("\n%s derives\n", symbol_name[i]);
  580. X      rp = first_derives + i * WORDSIZE(nrules);
  581. X      cword = *rp++;
  582. X      mask = 1;
  583. X      for (j = 0; j <= nrules; j++)
  584. X        {
  585. X      if (cword & mask)
  586. X        printf("   %d\n", j);
  587. X
  588. X      mask <<= 1;
  589. X      if (mask == 0)
  590. X        {
  591. X          cword = *rp++;
  592. X          mask = 1;
  593. X        }
  594. X    }
  595. X    }
  596. X
  597. X  fflush(stdout);
  598. X}
  599. X
  600. X#endif
  601. END_OF_FILE
  602. if test 4358 -ne `wc -c <'closure.c'`; then
  603.     echo shar: \"'closure.c'\" unpacked with wrong size!
  604. fi
  605. # end of 'closure.c'
  606. fi
  607. if test -f 'defs.h' -a "${1}" != "-c" ; then 
  608.   echo shar: Will not clobber existing file \"'defs.h'\"
  609. else
  610. echo shar: Extracting \"'defs.h'\" \(5738 characters\)
  611. sed "s/^X//" >'defs.h' <<'END_OF_FILE'
  612. X#include <assert.h>
  613. X#include <ctype.h>
  614. X#include <stdio.h>
  615. X
  616. X
  617. X/*  machine dependent definitions            */
  618. X/*  the following definitions are for the VAX        */
  619. X/*  they might have to be changed for other machines    */
  620. X
  621. X/*  MAXCHAR is the largest character value        */
  622. X/*  MAXSHORT is the largest value of a C short        */
  623. X/*  MINSHORT is the most negative value of a C short    */
  624. X/*  MAXTABLE is the maximum table size            */
  625. X/*  BITS_PER_WORD is the number of bits in a C unsigned    */
  626. X/*  WORDSIZE computes the number of words needed to    */
  627. X/*    store n bits                    */
  628. X/*  BIT returns the value of the n-th bit starting    */
  629. X/*    from r (0-indexed)                */
  630. X/*  SETBIT sets the n-th bit starting from r        */
  631. X
  632. X#define    MAXCHAR        255
  633. X#define    MAXSHORT    32767
  634. X#define MINSHORT    -32768
  635. X#define MAXTABLE    32500
  636. X#define BITS_PER_WORD    32
  637. X#define    WORDSIZE(n)    (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
  638. X#define    BIT(r, n)    ((((r)[(n) >> 5]) >> ((n) & 31)) & 1)
  639. X#define    SETBIT(r, n)    ((r)[(n) >> 5] |= (1 << ((n) & 31)))
  640. X
  641. X
  642. X/*  character names  */
  643. X
  644. X#define    NUL        '\0'    /*  the null character  */
  645. X#define    NEWLINE        '\n'    /*  line feed  */
  646. X#define    SP        ' '     /*  space  */
  647. X#define    BS        '\b'    /*  backspace  */
  648. X#define    HT        '\t'    /*  horizontal tab  */
  649. X#define    VT        '\013'  /*  vertical tab  */
  650. X#define    CR        '\r'    /*  carriage return  */
  651. X#define    FF        '\f'    /*  form feed  */
  652. X#define    QUOTE        '\''    /*  single quote  */
  653. X#define    DOUBLE_QUOTE    '\"'    /*  double quote  */
  654. X#define    BACKSLASH    '\\'    /*  backslash  */
  655. X
  656. X
  657. X/* defines for constructing filenames */
  658. X
  659. X#define    DEFINES_SUFFIX    ".tab.h"
  660. X#define    OUTPUT_SUFFIX    ".tab.c"
  661. X#define    VERBOSE_SUFFIX    ".output"
  662. X
  663. X
  664. X/* keyword codes */
  665. X
  666. X#define TOKEN 0
  667. X#define LEFT 1
  668. X#define RIGHT 2
  669. X#define NONASSOC 3
  670. X#define MARK 4
  671. X#define TEXT 5
  672. X#define TYPE 6
  673. X#define START 7
  674. X#define UNION 8
  675. X#define IDENT 9
  676. X
  677. X
  678. X/*  symbol classes  */
  679. X
  680. X#define UNKNOWN 0
  681. X#define TERM 1
  682. X#define NONTERM 2
  683. X
  684. X
  685. X/*  the undefined value  */
  686. X
  687. X#define UNDEFINED (-1)
  688. X
  689. X
  690. X/*  action codes  */
  691. X
  692. X#define SHIFT 1
  693. X#define REDUCE 2
  694. X#define ERROR 3
  695. X
  696. X
  697. X/*  character macros  */
  698. X
  699. X#define IS_IDENT(c)    (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
  700. X#define    IS_OCTAL(c)    ((c) >= '0' && (c) <= '7')
  701. X#define    NUMERIC_VALUE(c)    ((c) - '0')
  702. X
  703. X
  704. X/*  symbol macros  */
  705. X
  706. X#define ISTOKEN(s)    ((s) < start_symbol)
  707. X#define ISVAR(s)    ((s) >= start_symbol)
  708. X
  709. X
  710. X/*  storage allocation macros  */
  711. X
  712. X#define    FREE(x)        (free((char*)(x)))
  713. X#define MALLOC(n)    (malloc((unsigned)(n)))
  714. X#define    NEW(t)        ((t*)allocate(sizeof(t)))
  715. X#define    NEW2(n,t)    ((t*)allocate((unsigned)((n)*sizeof(t))))
  716. X#define REALLOC(p,n)    (realloc((char*)(p),(unsigned)(n)))
  717. X
  718. X
  719. X/*  the structure of a symbol table entry  */
  720. X
  721. Xtypedef struct bucket bucket;
  722. Xstruct bucket
  723. X{
  724. X    struct bucket *link;
  725. X    struct bucket *next;
  726. X    char *name;
  727. X    char *tag;
  728. X    short value;
  729. X    short index;
  730. X    short prec;
  731. X    char class;
  732. X    char assoc;
  733. X};
  734. X
  735. X
  736. X/*  the structure of the LR(0) state machine  */
  737. X
  738. Xtypedef struct core core;
  739. Xstruct core
  740. X{
  741. X    struct core *next;
  742. X    struct core *link;
  743. X    short number;
  744. X    short accessing_symbol;
  745. X    short nitems;
  746. X    short items[1];
  747. X};
  748. X
  749. X
  750. X/*  the structure used to record shifts  */
  751. X
  752. Xtypedef struct shifts shifts;
  753. Xstruct shifts
  754. X{
  755. X    struct shifts *next;
  756. X    short number;
  757. X    short nshifts;
  758. X    short shift[1];
  759. X};
  760. X
  761. X
  762. X/*  the structure used to store reductions  */
  763. X
  764. Xtypedef struct reductions reductions;
  765. Xstruct reductions
  766. X{
  767. X    struct reductions *next;
  768. X    short number;
  769. X    short nreds;
  770. X    short rules[1];
  771. X};
  772. X
  773. X
  774. X/*  the structure used to represent parser actions  */
  775. X
  776. Xtypedef struct action action;
  777. Xstruct action
  778. X{
  779. X    struct action *next;
  780. X    short symbol;
  781. X    short number;
  782. X    short prec;
  783. X    char action_code;
  784. X    char assoc;
  785. X    char suppressed;
  786. X};
  787. X
  788. X
  789. X/* global variables */
  790. X
  791. Xextern char dflag;
  792. Xextern char lflag;
  793. Xextern char tflag;
  794. Xextern char vflag;
  795. X
  796. Xextern char *myname;
  797. Xextern char *cptr;
  798. Xextern char *line;
  799. Xextern int lineno;
  800. Xextern int outline;
  801. X
  802. Xextern char *banner[];
  803. Xextern char *header[];
  804. Xextern char *body[];
  805. Xextern char *trailer[];
  806. X
  807. Xextern char *action_file_name;
  808. Xextern char *defines_file_name;
  809. Xextern char *input_file_name;
  810. Xextern char *output_file_name;
  811. Xextern char *text_file_name;
  812. Xextern char *union_file_name;
  813. Xextern char *verbose_file_name;
  814. X
  815. Xextern FILE *action_file;
  816. Xextern FILE *defines_file;
  817. Xextern FILE *input_file;
  818. Xextern FILE *output_file;
  819. Xextern FILE *text_file;
  820. Xextern FILE *union_file;
  821. Xextern FILE *verbose_file;
  822. X
  823. Xextern int nitems;
  824. Xextern int nrules;
  825. Xextern int nsyms;
  826. Xextern int ntokens;
  827. Xextern int nvars;
  828. Xextern int ntags;
  829. X
  830. Xextern char unionized;
  831. Xextern char line_format[];
  832. X
  833. Xextern int   start_symbol;
  834. Xextern char  **symbol_name;
  835. Xextern short *symbol_value;
  836. Xextern short *symbol_prec;
  837. Xextern char  *symbol_assoc;
  838. X
  839. Xextern short *ritem;
  840. Xextern short *rlhs;
  841. Xextern short *rrhs;
  842. Xextern short *rprec;
  843. Xextern char  *rassoc;
  844. X
  845. Xextern short **derives;
  846. Xextern char *nullable;
  847. X
  848. Xextern bucket *first_symbol;
  849. Xextern bucket *last_symbol;
  850. X
  851. Xextern int nstates;
  852. Xextern core *first_state;
  853. Xextern shifts *first_shift;
  854. Xextern reductions *first_reduction;
  855. Xextern short *accessing_symbol;
  856. Xextern core **state_table;
  857. Xextern shifts **shift_table;
  858. Xextern reductions **reduction_table;
  859. Xextern unsigned *LA;
  860. Xextern short *LAruleno;
  861. Xextern short *lookaheads;
  862. Xextern short *goto_map;
  863. Xextern short *from_state;
  864. Xextern short *to_state;
  865. X
  866. Xextern action **parser;
  867. Xextern int SRtotal;
  868. Xextern int RRtotal;
  869. Xextern short *SRconflicts;
  870. Xextern short *RRconflicts;
  871. Xextern short *defred;
  872. Xextern short *rules_used;
  873. Xextern short nunused;
  874. Xextern short final_state;
  875. X
  876. X/* global functions */
  877. X
  878. Xextern char *allocate();
  879. Xextern bucket *lookup();
  880. Xextern bucket *make_bucket();
  881. X
  882. X
  883. X/* system variables */
  884. X
  885. Xextern int errno;
  886. X
  887. X
  888. X/* system functions */
  889. X
  890. Xextern void free();
  891. Xextern char *calloc();
  892. Xextern char *malloc();
  893. Xextern char *realloc();
  894. Xextern char *strcpy();
  895. END_OF_FILE
  896. if test 5738 -ne `wc -c <'defs.h'`; then
  897.     echo shar: \"'defs.h'\" unpacked with wrong size!
  898. fi
  899. # end of 'defs.h'
  900. fi
  901. if test -f 'error.c' -a "${1}" != "-c" ; then 
  902.   echo shar: Will not clobber existing file \"'error.c'\"
  903. else
  904. echo shar: Extracting \"'error.c'\" \(6051 characters\)
  905. sed "s/^X//" >'error.c' <<'END_OF_FILE'
  906. X/* routines for printing error messages  */
  907. X
  908. X#include "defs.h"
  909. X
  910. X
  911. Xfatal(msg)
  912. Xchar *msg;
  913. X{
  914. X    fprintf(stderr, "%s: f - %s\n", myname, msg);
  915. X    done(2);
  916. X}
  917. X
  918. X
  919. Xno_space()
  920. X{
  921. X    fprintf(stderr, "%s: f - out of space\n", myname);
  922. X    done(2);
  923. X}
  924. X
  925. X
  926. Xopen_error(filename)
  927. Xchar *filename;
  928. X{
  929. X    fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
  930. X    done(2);
  931. X}
  932. X
  933. X
  934. Xunexpected_EOF()
  935. X{
  936. X    fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
  937. X        myname, lineno, input_file_name);
  938. X    done(1);
  939. X}
  940. X
  941. X
  942. Xprint_pos(st_line, st_cptr)
  943. Xchar *st_line;
  944. Xchar *st_cptr;
  945. X{
  946. X    register char *s;
  947. X
  948. X    if (st_line == 0) return;
  949. X    for (s = st_line; *s != '\n'; ++s)
  950. X    {
  951. X    if (isprint(*s) || *s == '\t')
  952. X        putc(*s, stderr);
  953. X    else
  954. X        putc('?', stderr);
  955. X    }
  956. X    putc('\n', stderr);
  957. X    for (s = st_line; s < st_cptr; ++s)
  958. X    {
  959. X    if (*s == '\t')
  960. X        putc('\t', stderr);
  961. X    else
  962. X        putc(' ', stderr);
  963. X    }
  964. X    putc('^', stderr);
  965. X    putc('\n', stderr);
  966. X}
  967. X
  968. X
  969. Xsyntax_error(st_lineno, st_line, st_cptr)
  970. Xint st_lineno;
  971. Xchar *st_line;
  972. Xchar *st_cptr;
  973. X{
  974. X    fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
  975. X        myname, st_lineno, input_file_name);
  976. X    print_pos(st_line, st_cptr);
  977. X    done(1);
  978. X}
  979. X
  980. X
  981. Xunterminated_comment(c_lineno, c_line, c_cptr)
  982. Xint c_lineno;
  983. Xchar *c_line;
  984. Xchar *c_cptr;
  985. X{
  986. X    fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
  987. X        myname, c_lineno, input_file_name);
  988. X    print_pos(c_line, c_cptr);
  989. X    done(1);
  990. X}
  991. X
  992. X
  993. Xunterminated_string(s_lineno, s_line, s_cptr)
  994. Xint s_lineno;
  995. Xchar *s_line;
  996. Xchar *s_cptr;
  997. X{
  998. X    fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
  999. X        myname, s_lineno, input_file_name);
  1000. X    print_pos(s_line, s_cptr);
  1001. X    done(1);
  1002. X}
  1003. X
  1004. X
  1005. Xunterminated_text(t_lineno, t_line, t_cptr)
  1006. Xint t_lineno;
  1007. Xchar *t_line;
  1008. Xchar *t_cptr;
  1009. X{
  1010. X    fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
  1011. X        myname, t_lineno, input_file_name);
  1012. X    print_pos(t_line, t_cptr);
  1013. X    done(1);
  1014. X}
  1015. X
  1016. X
  1017. Xunterminated_union(u_lineno, u_line, u_cptr)
  1018. Xint u_lineno;
  1019. Xchar *u_line;
  1020. Xchar *u_cptr;
  1021. X{
  1022. X    fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
  1023. Xdeclaration\n", myname, u_lineno, input_file_name);
  1024. X    print_pos(u_line, u_cptr);
  1025. X    done(1);
  1026. X}
  1027. X
  1028. X
  1029. Xover_unionized(u_cptr)
  1030. Xchar *u_cptr;
  1031. X{
  1032. X    fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
  1033. Xdeclarations\n", myname, lineno, input_file_name);
  1034. X    print_pos(line, u_cptr);
  1035. X    done(1);
  1036. X}
  1037. X
  1038. X
  1039. Xillegal_tag(t_lineno, t_line, t_cptr)
  1040. Xint t_lineno;
  1041. Xchar *t_line;
  1042. Xchar *t_cptr;
  1043. X{
  1044. X    fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
  1045. X        myname, t_lineno, input_file_name);
  1046. X    print_pos(t_line, t_cptr);
  1047. X    done(1);
  1048. X}
  1049. X
  1050. X
  1051. Xillegal_character(c_cptr)
  1052. Xchar *c_cptr;
  1053. X{
  1054. X    fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
  1055. X        myname, lineno, input_file_name);
  1056. X    print_pos(line, c_cptr);
  1057. X    done(1);
  1058. X}
  1059. X
  1060. X
  1061. Xused_reserved(s)
  1062. Xchar *s;
  1063. X{
  1064. X    fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
  1065. X%s\n", myname, lineno, input_file_name, s);
  1066. X    done(1);
  1067. X}
  1068. X
  1069. X
  1070. Xtokenized_start(s)
  1071. Xchar *s;
  1072. X{
  1073. X     fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
  1074. Xdeclared to be a token\n", myname, lineno, input_file_name, s);
  1075. X     done(1);
  1076. X}
  1077. X
  1078. X
  1079. Xretyped_warning(s)
  1080. Xchar *s;
  1081. X{
  1082. X    fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
  1083. Xredeclared\n", myname, lineno, input_file_name, s);
  1084. X}
  1085. X
  1086. X
  1087. Xreprec_warning(s)
  1088. Xchar *s;
  1089. X{
  1090. X    fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
  1091. Xredeclared\n", myname, lineno, input_file_name, s);
  1092. X}
  1093. X
  1094. X
  1095. Xrevalued_warning(s)
  1096. Xchar *s;
  1097. X{
  1098. X    fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
  1099. Xredeclared\n", myname, lineno, input_file_name, s);
  1100. X}
  1101. X
  1102. X
  1103. Xterminal_start(s)
  1104. Xchar *s;
  1105. X{
  1106. X    fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
  1107. Xtoken\n", myname, lineno, input_file_name, s);
  1108. X    done(1);
  1109. X}
  1110. X
  1111. X
  1112. Xrestarted_warning()
  1113. X{
  1114. X    fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
  1115. Xredeclared\n", myname, lineno, input_file_name);
  1116. X}
  1117. X
  1118. X
  1119. Xno_grammar()
  1120. X{
  1121. X    fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
  1122. Xspecified\n", myname, lineno, input_file_name);
  1123. X    done(1);
  1124. X}
  1125. X
  1126. X
  1127. Xterminal_lhs(s_lineno)
  1128. Xint s_lineno;
  1129. X{
  1130. X    fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
  1131. Xof a production\n", myname, s_lineno, input_file_name);
  1132. X    done(1);
  1133. X}
  1134. X
  1135. X
  1136. Xprec_redeclared()
  1137. X{
  1138. X    fprintf(stderr, "%s: w - line %d of  \"%s\", conflicting %%prec \
  1139. Xspecifiers\n", myname, lineno, input_file_name);
  1140. X}
  1141. X
  1142. X
  1143. Xunterminated_action(a_lineno, a_line, a_cptr)
  1144. Xint a_lineno;
  1145. Xchar *a_line;
  1146. Xchar *a_cptr;
  1147. X{
  1148. X    fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
  1149. X        myname, a_lineno, input_file_name);
  1150. X    print_pos(a_line, a_cptr);
  1151. X    done(1);
  1152. X}
  1153. X
  1154. X
  1155. Xdollar_warning(a_lineno, i)
  1156. Xint a_lineno;
  1157. Xint i;
  1158. X{
  1159. X    fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
  1160. Xend of the current rule\n", myname, a_lineno, input_file_name, i);
  1161. X}
  1162. X
  1163. X
  1164. Xdollar_error(a_lineno, a_line, a_cptr)
  1165. Xint a_lineno;
  1166. Xchar *a_line;
  1167. Xchar *a_cptr;
  1168. X{
  1169. X    fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
  1170. X        myname, a_lineno, input_file_name);
  1171. X    print_pos(a_line, a_cptr);
  1172. X    done(1);
  1173. X}
  1174. X
  1175. X
  1176. Xuntyped_lhs()
  1177. X{
  1178. X    fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
  1179. X        myname, lineno, input_file_name);
  1180. X    done(1);
  1181. X}
  1182. X
  1183. X
  1184. Xuntyped_rhs(i, s)
  1185. Xint i;
  1186. Xchar *s;
  1187. X{
  1188. X    fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
  1189. X        myname, lineno, input_file_name, i, s);
  1190. X    done(1);
  1191. X}
  1192. X
  1193. X
  1194. Xunknown_rhs(i)
  1195. Xint i;
  1196. X{
  1197. X    fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
  1198. X        myname, lineno, input_file_name, i);
  1199. X    done(1);
  1200. X}
  1201. X
  1202. X
  1203. Xdefault_action_warning()
  1204. X{
  1205. X    fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
  1206. Xundefined value to $$\n", myname, lineno, input_file_name);
  1207. X}
  1208. X
  1209. X
  1210. Xundefined_goal(s)
  1211. Xchar *s;
  1212. X{
  1213. X    fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
  1214. X    done(1);
  1215. X}
  1216. X
  1217. X
  1218. Xundefined_symbol_warning(s)
  1219. Xchar *s;
  1220. X{
  1221. X    fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
  1222. X}
  1223. END_OF_FILE
  1224. if test 6051 -ne `wc -c <'error.c'`; then
  1225.     echo shar: \"'error.c'\" unpacked with wrong size!
  1226. fi
  1227. # end of 'error.c'
  1228. fi
  1229. if test -f 'main.c' -a "${1}" != "-c" ; then 
  1230.   echo shar: Will not clobber existing file \"'main.c'\"
  1231. else
  1232. echo shar: Extracting \"'main.c'\" \(5864 characters\)
  1233. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  1234. X#include <signal.h>
  1235. X#include "defs.h"
  1236. X
  1237. Xchar dflag;
  1238. Xchar lflag;
  1239. Xchar tflag;
  1240. Xchar vflag;
  1241. X
  1242. Xchar *prefix = "y";
  1243. Xchar *myname = "yacc";
  1244. Xchar *temp_form = "yacc.XXXXXXX";
  1245. X
  1246. Xint lineno;
  1247. Xint outline;
  1248. X
  1249. Xchar *action_file_name;
  1250. Xchar *defines_file_name;
  1251. Xchar *input_file_name = "";
  1252. Xchar *output_file_name;
  1253. Xchar *text_file_name;
  1254. Xchar *union_file_name;
  1255. Xchar *verbose_file_name;
  1256. X
  1257. XFILE *action_file;    /*  a temp file, used to save actions associated    */
  1258. X            /*  with rules until the parser is written        */
  1259. XFILE *defines_file;    /*  y.tab.h                        */
  1260. XFILE *input_file;    /*  the input file                    */
  1261. XFILE *output_file;    /*  y.tab.c                        */
  1262. XFILE *text_file;    /*  a temp file, used to save text until all        */
  1263. X            /*  symbols have been defined                */
  1264. XFILE *union_file;    /*  a temp file, used to save the union            */
  1265. X            /*  definition until all symbol have been        */
  1266. X            /*  defined                        */
  1267. XFILE *verbose_file;    /*  y.output                        */
  1268. X
  1269. Xint nitems;
  1270. Xint nrules;
  1271. Xint nsyms;
  1272. Xint ntokens;
  1273. Xint nvars;
  1274. X
  1275. Xint   start_symbol;
  1276. Xchar  **symbol_name;
  1277. Xshort *symbol_value;
  1278. Xshort *symbol_prec;
  1279. Xchar  *symbol_assoc;
  1280. X
  1281. Xshort *ritem;
  1282. Xshort *rlhs;
  1283. Xshort *rrhs;
  1284. Xshort *rprec;
  1285. Xchar  *rassoc;
  1286. Xshort **derives;
  1287. Xchar *nullable;
  1288. X
  1289. Xextern char *mktemp();
  1290. Xextern char *getenv();
  1291. X
  1292. X
  1293. Xdone(k)
  1294. Xint k;
  1295. X{
  1296. X    if (action_file) { fclose(action_file); unlink(action_file_name); }
  1297. X    if (text_file) { fclose(text_file); unlink(text_file_name); }
  1298. X    if (union_file) { fclose(union_file); unlink(union_file_name); }
  1299. X    exit(k);
  1300. X}
  1301. X
  1302. X
  1303. Xonintr()
  1304. X{
  1305. X    done(1);
  1306. X}
  1307. X
  1308. X
  1309. Xset_signals()
  1310. X{
  1311. X#ifdef SIGINT
  1312. X    if (signal(SIGINT, SIG_IGN) != SIG_IGN)
  1313. X    signal(SIGINT, onintr);
  1314. X#endif
  1315. X#ifdef SIGTERM
  1316. X    if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
  1317. X    signal(SIGTERM, onintr);
  1318. X#endif
  1319. X#ifdef SIGHUP
  1320. X    if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
  1321. X    signal(SIGHUP, onintr);
  1322. X#endif
  1323. X}
  1324. X
  1325. X
  1326. Xusage()
  1327. X{
  1328. X    fprintf(stderr, "usage: %s [-dltv] [-b prefix] filename\n", myname);
  1329. X    exit(1);
  1330. X}
  1331. X
  1332. X
  1333. Xgetargs(argc, argv)
  1334. Xint argc;
  1335. Xchar *argv[];
  1336. X{
  1337. X    register int i;
  1338. X    register char *s;
  1339. X
  1340. X    if (argc > 0) myname = argv[0];
  1341. X    for (i = 1; i < argc; ++i)
  1342. X    {
  1343. X    s = argv[i];
  1344. X    if (*s != '-') break;
  1345. X    switch (*++s)
  1346. X    {
  1347. X    case '\0':
  1348. X        input_file = stdin;
  1349. X        if (i + 1 < argc) usage();
  1350. X        return;
  1351. X
  1352. X    case '_':
  1353. X        ++i;
  1354. X        goto no_more_options;
  1355. X
  1356. X    case 'b':
  1357. X        if (*++s || ++i >= argc) usage();
  1358. X        prefix = argv[i];
  1359. X        continue;
  1360. X
  1361. X    case 'd':
  1362. X        dflag = 1;
  1363. X        break;
  1364. X
  1365. X    case 'l':
  1366. X        lflag = 1;
  1367. X        break;
  1368. X
  1369. X    case 't':
  1370. X        tflag = 1;
  1371. X        break;
  1372. X
  1373. X    case 'v':
  1374. X        vflag = 1;
  1375. X        break;
  1376. X
  1377. X    default:
  1378. X        usage();
  1379. X    }
  1380. X
  1381. X    for (;;)
  1382. X    {
  1383. X        switch (*++s)
  1384. X        {
  1385. X        case '\0':
  1386. X        goto end_of_option;
  1387. X
  1388. X        case 'd':
  1389. X        dflag = 1;
  1390. X        break;
  1391. X
  1392. X        case 'l':
  1393. X        lflag = 1;
  1394. X        break;
  1395. X
  1396. X        case 't':
  1397. X        tflag = 1;
  1398. X        break;
  1399. X
  1400. X        case 'v':
  1401. X        vflag = 1;
  1402. X        break;
  1403. X
  1404. X        default:
  1405. X        usage();
  1406. X        }
  1407. X    }
  1408. Xend_of_option:;
  1409. X    }
  1410. X
  1411. Xno_more_options:;
  1412. X    if (i + 1 != argc) usage();
  1413. X    input_file_name = argv[i];
  1414. X}
  1415. X
  1416. X
  1417. Xchar *
  1418. Xallocate(n)
  1419. Xunsigned n;
  1420. X{
  1421. X    register char *p;
  1422. X
  1423. X    p = calloc((unsigned) 1, n);
  1424. X    if (!p) no_space();
  1425. X    return (p);
  1426. X}
  1427. X
  1428. X
  1429. Xcreate_file_names()
  1430. X{
  1431. X    int i, len;
  1432. X    char *tmpdir;
  1433. X
  1434. X    tmpdir = getenv("TMPDIR");
  1435. X    if (tmpdir == 0) tmpdir = "/tmp";
  1436. X
  1437. X    len = strlen(tmpdir);
  1438. X    i = len + 13;
  1439. X    if (len && tmpdir[len-1] != '/')
  1440. X    ++i;
  1441. X
  1442. X    action_file_name = MALLOC(i);
  1443. X    if (action_file_name == 0) no_space();
  1444. X    text_file_name = MALLOC(i);
  1445. X    if (text_file_name == 0) no_space();
  1446. X    union_file_name = MALLOC(i);
  1447. X    if (union_file_name == 0) no_space();
  1448. X
  1449. X    strcpy(action_file_name, tmpdir);
  1450. X    strcpy(text_file_name, tmpdir);
  1451. X    strcpy(union_file_name, tmpdir);
  1452. X
  1453. X    if (len && tmpdir[len - 1] != '/')
  1454. X    {
  1455. X    action_file_name[len] = '/';
  1456. X    text_file_name[len] = '/';
  1457. X    union_file_name[len] = '/';
  1458. X    ++len;
  1459. X    }
  1460. X
  1461. X    strcpy(action_file_name + len, temp_form);
  1462. X    strcpy(text_file_name + len, temp_form);
  1463. X    strcpy(union_file_name + len, temp_form);
  1464. X
  1465. X    action_file_name[len + 5] = 'a';
  1466. X    text_file_name[len + 5] = 't';
  1467. X    union_file_name[len + 5] = 'u';
  1468. X
  1469. X    mktemp(action_file_name);
  1470. X    mktemp(text_file_name);
  1471. X    mktemp(union_file_name);
  1472. X
  1473. X    len = strlen(prefix);
  1474. X    if (dflag)
  1475. X    {
  1476. X    /*  the number 7 below is the size of ".tab.h"; sizeof is not used  */
  1477. X    /*  because of a C compiler that thinks sizeof(".tab.h") == 6        */
  1478. X    defines_file_name = MALLOC(len + 7);
  1479. X    if (defines_file_name == 0) no_space();
  1480. X    strcpy(defines_file_name, prefix);
  1481. X    strcpy(defines_file_name + len, DEFINES_SUFFIX);
  1482. X    }
  1483. X
  1484. X    output_file_name = MALLOC(len + 7);
  1485. X    if (output_file_name == 0) no_space();
  1486. X    strcpy(output_file_name, prefix);
  1487. X    strcpy(output_file_name + len, OUTPUT_SUFFIX);
  1488. X
  1489. X    if (vflag)
  1490. X    {
  1491. X    verbose_file_name = MALLOC(len + 8);
  1492. X    if (verbose_file_name == 0) no_space();
  1493. X    strcpy(verbose_file_name, prefix);
  1494. X    strcpy(verbose_file_name + len, VERBOSE_SUFFIX);
  1495. X    }
  1496. X}
  1497. X
  1498. X
  1499. Xopen_files()
  1500. X{
  1501. X    create_file_names();
  1502. X
  1503. X    if (input_file == 0)
  1504. X    {
  1505. X    input_file = fopen(input_file_name, "r");
  1506. X    if (input_file == 0) open_error(input_file_name);
  1507. X    }
  1508. X
  1509. X    action_file = fopen(action_file_name, "w");
  1510. X    if (action_file == 0) open_error(action_file_name);
  1511. X
  1512. X    text_file = fopen(text_file_name, "w");
  1513. X    if (text_file == 0) open_error(text_file_name);
  1514. X
  1515. X    if (vflag)
  1516. X    {
  1517. X    verbose_file = fopen(verbose_file_name, "w");
  1518. X    if (verbose_file == 0) open_error(verbose_file_name);
  1519. X    }
  1520. X
  1521. X    if (dflag)
  1522. X    {
  1523. X    defines_file = fopen(defines_file_name, "w");
  1524. X    if (defines_file == 0) open_error(defines_file_name);
  1525. X    union_file = fopen(union_file_name, "w");
  1526. X    if (union_file ==  0) open_error(union_file_name);
  1527. X    }
  1528. X
  1529. X    output_file = fopen(output_file_name, "w");
  1530. X    if (output_file == 0) open_error(output_file_name);
  1531. X}
  1532. X
  1533. X
  1534. Xint
  1535. Xmain(argc, argv)
  1536. Xint argc;
  1537. Xchar *argv[];
  1538. X{
  1539. X    set_signals();
  1540. X    getargs(argc, argv);
  1541. X    open_files();
  1542. X    reader();
  1543. X    lr0();
  1544. X    lalr();
  1545. X    make_parser();
  1546. X    verbose();
  1547. X    output();
  1548. X    done(0);
  1549. X    /*NOTREACHED*/
  1550. X}
  1551. END_OF_FILE
  1552. if test 5864 -ne `wc -c <'main.c'`; then
  1553.     echo shar: \"'main.c'\" unpacked with wrong size!
  1554. fi
  1555. # end of 'main.c'
  1556. fi
  1557. if test -f 'manpage' -a "${1}" != "-c" ; then 
  1558.   echo shar: Will not clobber existing file \"'manpage'\"
  1559. else
  1560. echo shar: Extracting \"'manpage'\" \(2394 characters\)
  1561. sed "s/^X//" >'manpage' <<'END_OF_FILE'
  1562. X.\"    %W%    %R% (Berkeley) %E%
  1563. X.\"
  1564. X.TH YACC 1 "December 10, 1989"
  1565. X.UC 6
  1566. X.SH NAME
  1567. XYacc \- an LALR(1) parser generator
  1568. X.SH SYNOPSIS
  1569. X.B yacc [ -dltv ] [ -b
  1570. X.I prefix
  1571. X.B ]
  1572. X.I filename
  1573. X.SH DESCRIPTION
  1574. X.I Yacc
  1575. Xreads the grammar specification in the file
  1576. X.I filename
  1577. Xand generates an LR(1) parser for it.
  1578. XThe parsers consist of a set of LALR(1) parsing tables and a driver routine
  1579. Xwritten in the C programming language.
  1580. X.I Yacc
  1581. Xnormally writes the parse tables and the driver routine to the file
  1582. X.IR y.tab.c.
  1583. X.PP
  1584. XThe following options are available:
  1585. X.RS
  1586. X.TP
  1587. X\fB-b \fIprefix\fR
  1588. XThe
  1589. X.B -b
  1590. Xoption changes the prefix prepended to the output file names to
  1591. Xthe string denoted by
  1592. X.IR prefix.
  1593. XThe default prefix is the character
  1594. X.IR y.
  1595. X.TP
  1596. X.B -d
  1597. XThe \fB-d\fR option causes the header file
  1598. X.IR y.tab.h
  1599. Xto be written.
  1600. X.TP
  1601. X.B -l
  1602. XIf the
  1603. X.B -l
  1604. Xoption is not specified,
  1605. X.I yacc
  1606. Xwill insert \#line directives in the generated code.
  1607. XThe \#line directives let the C compiler relate errors in the
  1608. Xgenerated code to the user's original code.
  1609. XIf the \fB-l\fR option is specified,
  1610. X.I yacc
  1611. Xwill not insert the \#line directives.
  1612. X\&\#line directives specified by the user will be retained.
  1613. X.TP
  1614. X.B -t
  1615. XThe
  1616. X.B -t
  1617. Xoption will change the preprocessor directives generated by
  1618. X.I yacc
  1619. Xso that debugging statements will be incorporated in the compiled code.
  1620. X.TP
  1621. X.B -v
  1622. XThe
  1623. X.B -v
  1624. Xoption causes a human-readable description of the generated parser to
  1625. Xbe written to the file
  1626. X.IR y.output.
  1627. X.RE
  1628. X.PP
  1629. XIf the environment variable TMPDIR is set, the string denoted by
  1630. XTMPDIR will be used as the name of the directory where the temporary
  1631. Xfiles are created.
  1632. X.SH TABLES
  1633. XThere is a program \fI:yyfix\fR
  1634. Xthat extracts tables from \fIyacc\fR-generated
  1635. Xfiles.
  1636. XThe program takes the names of the tables as its command-line arguments.
  1637. XThe names of the tables generated by this version of
  1638. X.I yacc
  1639. Xare
  1640. X.IR yylhs,
  1641. X.IR yylen,
  1642. X.IR yydefred,
  1643. X.IR yydgoto,
  1644. X.IR yysindex,
  1645. X.IR yyrindex,
  1646. X.IR yygindex,
  1647. X.IR yytable,
  1648. Xand
  1649. X.IR yycheck.
  1650. XTwo additional tables,
  1651. X.I yyname
  1652. Xand
  1653. X.I yyrule,
  1654. Xare created if YYDEBUG is defined and nonzero.
  1655. X.SH FILES
  1656. X.IR y.tab.c
  1657. X.br
  1658. X.IR y.tab.h
  1659. X.br
  1660. X.IR y.output
  1661. X.br
  1662. X.IR /tmp/yacc.aXXXXXX
  1663. X.br
  1664. X.IR /tmp/yacc.tXXXXXX
  1665. X.br
  1666. X.IR /tmp/yacc.uXXXXXX
  1667. X.SH DIAGNOSTICS
  1668. XIf there are rules that are never reduced, the number of such rules is
  1669. Xreported on standard error.
  1670. XIf there are any LALR(1) conflicts, the number of conflicts is reported
  1671. Xon standard error.
  1672. END_OF_FILE
  1673. if test 2394 -ne `wc -c <'manpage'`; then
  1674.     echo shar: \"'manpage'\" unpacked with wrong size!
  1675. fi
  1676. # end of 'manpage'
  1677. fi
  1678. if test -f 'symtab.c' -a "${1}" != "-c" ; then 
  1679.   echo shar: Will not clobber existing file \"'symtab.c'\"
  1680. else
  1681. echo shar: Extracting \"'symtab.c'\" \(1841 characters\)
  1682. sed "s/^X//" >'symtab.c' <<'END_OF_FILE'
  1683. X#include "defs.h"
  1684. X
  1685. X
  1686. X/* TABLE_SIZE is the number of entries in the symbol table. */
  1687. X/* TABLE_SIZE must be a power of two.                */
  1688. X
  1689. X#define    TABLE_SIZE 1024
  1690. X
  1691. X
  1692. Xbucket **symbol_table;
  1693. Xbucket *first_symbol;
  1694. Xbucket *last_symbol;
  1695. X
  1696. X
  1697. Xint
  1698. Xhash(name)
  1699. Xchar *name;
  1700. X{
  1701. X    register char *s;
  1702. X    register int c, k;
  1703. X
  1704. X    assert(name && *name);
  1705. X    s = name;
  1706. X    k = *s;
  1707. X    while (c = *++s)
  1708. X    k = (31*k + c) & (TABLE_SIZE - 1);
  1709. X
  1710. X    return (k);
  1711. X}
  1712. X
  1713. X
  1714. Xbucket *
  1715. Xmake_bucket(name)
  1716. Xchar *name;
  1717. X{
  1718. X    register bucket *bp;
  1719. X
  1720. X    assert(name);
  1721. X    bp = (bucket *) MALLOC(sizeof(bucket));
  1722. X    if (bp == 0) no_space();
  1723. X    bp->link = 0;
  1724. X    bp->next = 0;
  1725. X    bp->name = MALLOC(strlen(name) + 1);
  1726. X    if (bp->name == 0) no_space();
  1727. X    bp->tag = 0;
  1728. X    bp->value = UNDEFINED;
  1729. X    bp->index = 0;
  1730. X    bp->prec = 0;
  1731. X    bp-> class = UNKNOWN;
  1732. X    bp->assoc = TOKEN;
  1733. X
  1734. X    if (bp->name == 0) no_space();
  1735. X    strcpy(bp->name, name);
  1736. X
  1737. X    return (bp);
  1738. X}
  1739. X
  1740. X
  1741. Xbucket *
  1742. Xlookup(name)
  1743. Xchar *name;
  1744. X{
  1745. X    register bucket *bp, **bpp;
  1746. X
  1747. X    bpp = symbol_table + hash(name);
  1748. X    bp = *bpp;
  1749. X
  1750. X    while (bp)
  1751. X    {
  1752. X    if (strcmp(name, bp->name) == 0) return (bp);
  1753. X    bpp = &bp->link;
  1754. X    bp = *bpp;
  1755. X    }
  1756. X
  1757. X    *bpp = bp = make_bucket(name);
  1758. X    last_symbol->next = bp;
  1759. X    last_symbol = bp;
  1760. X
  1761. X    return (bp);
  1762. X}
  1763. X
  1764. X
  1765. Xcreate_symbol_table()
  1766. X{
  1767. X    register int i;
  1768. X    register bucket *bp;
  1769. X
  1770. X    symbol_table = (bucket **) MALLOC(TABLE_SIZE*sizeof(bucket *));
  1771. X    if (symbol_table == 0) no_space();
  1772. X    for (i = 0; i < TABLE_SIZE; i++)
  1773. X    symbol_table[i] = 0;
  1774. X
  1775. X    bp = make_bucket("error");
  1776. X    bp->index = 1;
  1777. X    bp->class = TERM;
  1778. X
  1779. X    first_symbol = bp;
  1780. X    last_symbol = bp;
  1781. X    symbol_table[hash("error")] = bp;
  1782. X}
  1783. X
  1784. X
  1785. Xfree_symbol_table()
  1786. X{
  1787. X    FREE(symbol_table);
  1788. X    symbol_table = 0;
  1789. X}
  1790. X
  1791. X
  1792. Xfree_symbols()
  1793. X{
  1794. X    register bucket *p, *q;
  1795. X
  1796. X    for (p = first_symbol; p; p = q)
  1797. X    {
  1798. X    q = p->next;
  1799. X    FREE(p);
  1800. X    }
  1801. X}
  1802. END_OF_FILE
  1803. if test 1841 -ne `wc -c <'symtab.c'`; then
  1804.     echo shar: \"'symtab.c'\" unpacked with wrong size!
  1805. fi
  1806. # end of 'symtab.c'
  1807. fi
  1808. if test ! -d 'test' ; then
  1809.     echo shar: Creating directory \"'test'\"
  1810.     mkdir 'test'
  1811. fi
  1812. if test -f 'test/error.output' -a "${1}" != "-c" ; then 
  1813.   echo shar: Will not clobber existing file \"'test/error.output'\"
  1814. else
  1815. echo shar: Extracting \"'test/error.output'\" \(262 characters\)
  1816. sed "s/^X//" >'test/error.output' <<'END_OF_FILE'
  1817. X   0  $accept : S $end
  1818. X
  1819. X   1  S : error
  1820. X
  1821. Xstate 0
  1822. X    $accept : . S $end  (0)
  1823. X
  1824. X    error  shift 1
  1825. X    .  error
  1826. X
  1827. X    S  goto 2
  1828. X
  1829. X
  1830. Xstate 1
  1831. X    S : error .  (1)
  1832. X
  1833. X    .  reduce 1
  1834. X
  1835. X
  1836. Xstate 2
  1837. X    $accept : S . $end  (0)
  1838. X
  1839. X    $end  accept
  1840. X
  1841. X
  1842. X2 terminals, 2 nonterminals
  1843. X2 grammar rules, 3 states
  1844. END_OF_FILE
  1845. if test 262 -ne `wc -c <'test/error.output'`; then
  1846.     echo shar: \"'test/error.output'\" unpacked with wrong size!
  1847. fi
  1848. # end of 'test/error.output'
  1849. fi
  1850. if test -f 'test/error.tab.c' -a "${1}" != "-c" ; then 
  1851.   echo shar: Will not clobber existing file \"'test/error.tab.c'\"
  1852. else
  1853. echo shar: Extracting \"'test/error.tab.c'\" \(6307 characters\)
  1854. sed "s/^X//" >'test/error.tab.c' <<'END_OF_FILE'
  1855. X#ifndef lint
  1856. Xchar yysccsid[] = "@(#)yaccpar    1.4 (Berkeley) 02/25/90";
  1857. X#endif
  1858. X#define YYERRCODE 256
  1859. Xshort yylhs[] = {                                        -1,
  1860. X    0,
  1861. X};
  1862. Xshort yylen[] = {                                         2,
  1863. X    1,
  1864. X};
  1865. Xshort yydefred[] = {                                      0,
  1866. X    1,    0,
  1867. X};
  1868. Xshort yydgoto[] = {                                       2,
  1869. X};
  1870. Xshort yysindex[] = {                                   -256,
  1871. X    0,    0,
  1872. X};
  1873. Xshort yyrindex[] = {                                      0,
  1874. X    0,    0,
  1875. X};
  1876. Xshort yygindex[] = {                                      0,
  1877. X};
  1878. X#define YYTABLESIZE 0
  1879. Xshort yytable[] = {                                       1,
  1880. X};
  1881. Xshort yycheck[] = {                                     256,
  1882. X};
  1883. X#define YYFINAL 2
  1884. X#ifndef YYDEBUG
  1885. X#define YYDEBUG 0
  1886. X#endif
  1887. X#define YYMAXTOKEN 0
  1888. X#if YYDEBUG
  1889. Xchar *yyname[] = {
  1890. X"end-of-file",
  1891. X};
  1892. Xchar *yyrule[] = {
  1893. X"$accept : S",
  1894. X"S : error",
  1895. X};
  1896. X#endif
  1897. X#ifndef YYSTYPE
  1898. Xtypedef int YYSTYPE;
  1899. X#endif
  1900. X#define yyclearin (yychar=(-1))
  1901. X#define yyerrok (yyerrflag=0)
  1902. X#ifndef YYSTACKSIZE
  1903. X#ifdef YYMAXDEPTH
  1904. X#define YYSTACKSIZE YYMAXDEPTH
  1905. X#else
  1906. X#define YYSTACKSIZE 300
  1907. X#endif
  1908. X#endif
  1909. Xint yydebug;
  1910. Xint yynerrs;
  1911. Xint yyerrflag;
  1912. Xint yychar;
  1913. Xshort *yyssp;
  1914. XYYSTYPE *yyvsp;
  1915. XYYSTYPE yyval;
  1916. XYYSTYPE yylval;
  1917. X#define yystacksize YYSTACKSIZE
  1918. Xshort yyss[YYSTACKSIZE];
  1919. XYYSTYPE yyvs[YYSTACKSIZE];
  1920. X#line 4 "error.y"
  1921. Xmain(){printf("yyparse() = %d\n",yyparse());}
  1922. Xyylex(){return-1;}
  1923. Xyyerror(s)char*s;{printf("%s\n",s);}
  1924. X#line 71 "error.tab.c"
  1925. X#define YYABORT goto yyabort
  1926. X#define YYACCEPT goto yyaccept
  1927. X#define YYERROR goto yyerrlab
  1928. Xint
  1929. Xyyparse()
  1930. X{
  1931. X    register int yym, yyn, yystate;
  1932. X#if YYDEBUG
  1933. X    register char *yys;
  1934. X    extern char *getenv();
  1935. X
  1936. X    if (yys = getenv("YYDEBUG"))
  1937. X    {
  1938. X        yyn = *yys;
  1939. X        if (yyn >= '0' && yyn <= '9')
  1940. X            yydebug = yyn - '0';
  1941. X    }
  1942. X#endif
  1943. X
  1944. X    yynerrs = 0;
  1945. X    yyerrflag = 0;
  1946. X    yychar = (-1);
  1947. X
  1948. X    yyssp = yyss;
  1949. X    yyvsp = yyvs;
  1950. X    *yyssp = yystate = 0;
  1951. X
  1952. Xyyloop:
  1953. X    if (yyn = yydefred[yystate]) goto yyreduce;
  1954. X    if (yychar < 0)
  1955. X    {
  1956. X        if ((yychar = yylex()) < 0) yychar = 0;
  1957. X#if YYDEBUG
  1958. X        if (yydebug)
  1959. X        {
  1960. X            yys = 0;
  1961. X            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1962. X            if (!yys) yys = "illegal-symbol";
  1963. X            printf("yydebug: state %d, reading %d (%s)\n", yystate,
  1964. X                    yychar, yys);
  1965. X        }
  1966. X#endif
  1967. X    }
  1968. X    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
  1969. X            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1970. X    {
  1971. X#if YYDEBUG
  1972. X        if (yydebug)
  1973. X            printf("yydebug: state %d, shifting to state %d\n",
  1974. X                    yystate, yytable[yyn]);
  1975. X#endif
  1976. X        if (yyssp >= yyss + yystacksize - 1)
  1977. X        {
  1978. X            goto yyoverflow;
  1979. X        }
  1980. X        *++yyssp = yystate = yytable[yyn];
  1981. X        *++yyvsp = yylval;
  1982. X        yychar = (-1);
  1983. X        if (yyerrflag > 0)  --yyerrflag;
  1984. X        goto yyloop;
  1985. X    }
  1986. X    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
  1987. X            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  1988. X    {
  1989. X        yyn = yytable[yyn];
  1990. X        goto yyreduce;
  1991. X    }
  1992. X    if (yyerrflag) goto yyinrecovery;
  1993. X#ifdef lint
  1994. X    goto yynewerror;
  1995. X#endif
  1996. Xyynewerror:
  1997. X    yyerror("syntax error");
  1998. X#ifdef lint
  1999. X    goto yyerrlab;
  2000. X#endif
  2001. Xyyerrlab:
  2002. X    ++yynerrs;
  2003. Xyyinrecovery:
  2004. X    if (yyerrflag < 3)
  2005. X    {
  2006. X        yyerrflag = 3;
  2007. X        for (;;)
  2008. X        {
  2009. X            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
  2010. X                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  2011. X            {
  2012. X#if YYDEBUG
  2013. X                if (yydebug)
  2014. X                    printf("yydebug: state %d, error recovery shifting\
  2015. X to state %d\n", *yyssp, yytable[yyn]);
  2016. X#endif
  2017. X                if (yyssp >= yyss + yystacksize - 1)
  2018. X                {
  2019. X                    goto yyoverflow;
  2020. X                }
  2021. X                *++yyssp = yystate = yytable[yyn];
  2022. X                *++yyvsp = yylval;
  2023. X                goto yyloop;
  2024. X            }
  2025. X            else
  2026. X            {
  2027. X#if YYDEBUG
  2028. X                if (yydebug)
  2029. X                    printf("yydebug: error recovery discarding state %d\n",
  2030. X                            *yyssp);
  2031. X#endif
  2032. X                if (yyssp <= yyss) goto yyabort;
  2033. X                --yyssp;
  2034. X                --yyvsp;
  2035. X            }
  2036. X        }
  2037. X    }
  2038. X    else
  2039. X    {
  2040. X        if (yychar == 0) goto yyabort;
  2041. X#if YYDEBUG
  2042. X        if (yydebug)
  2043. X        {
  2044. X            yys = 0;
  2045. X            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  2046. X            if (!yys) yys = "illegal-symbol";
  2047. X            printf("yydebug: state %d, error recovery discards token %d (%s)\n",
  2048. X                    yystate, yychar, yys);
  2049. X        }
  2050. X#endif
  2051. X        yychar = (-1);
  2052. X        goto yyloop;
  2053. X    }
  2054. Xyyreduce:
  2055. X#if YYDEBUG
  2056. X    if (yydebug)
  2057. X        printf("yydebug: state %d, reducing by rule %d (%s)\n",
  2058. X                yystate, yyn, yyrule[yyn]);
  2059. X#endif
  2060. X    yym = yylen[yyn];
  2061. X    yyval = yyvsp[1-yym];
  2062. X    switch (yyn)
  2063. X    {
  2064. X    }
  2065. X    yyssp -= yym;
  2066. X    yystate = *yyssp;
  2067. X    yyvsp -= yym;
  2068. X    yym = yylhs[yyn];
  2069. X    if (yystate == 0 && yym == 0)
  2070. X    {
  2071. X#ifdef YYDEBUG
  2072. X        if (yydebug)
  2073. X            printf("yydebug: after reduction, shifting from state 0 to\
  2074. X state %d\n", YYFINAL);
  2075. X#endif
  2076. X        yystate = YYFINAL;
  2077. X        *++yyssp = YYFINAL;
  2078. X        *++yyvsp = yyval;
  2079. X        if (yychar < 0)
  2080. X        {
  2081. X            if ((yychar = yylex()) < 0) yychar = 0;
  2082. X#if YYDEBUG
  2083. X            if (yydebug)
  2084. X            {
  2085. X                yys = 0;
  2086. X                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  2087. X                if (!yys) yys = "illegal-symbol";
  2088. X                printf("yydebug: state %d, reading %d (%s)\n",
  2089. X                        YYFINAL, yychar, yys);
  2090. X            }
  2091. X#endif
  2092. X        }
  2093. X        if (yychar == 0) goto yyaccept;
  2094. X        goto yyloop;
  2095. X    }
  2096. X    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
  2097. X            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  2098. X        yystate = yytable[yyn];
  2099. X    else
  2100. X        yystate = yydgoto[yym];
  2101. X#ifdef YYDEBUG
  2102. X    if (yydebug)
  2103. X        printf("yydebug: after reduction, shifting from state %d \
  2104. Xto state %d\n", *yyssp, yystate);
  2105. X#endif
  2106. X    if (yyssp >= yyss + yystacksize - 1)
  2107. X    {
  2108. X        goto yyoverflow;
  2109. X    }
  2110. X    *++yyssp = yystate;
  2111. X    *++yyvsp = yyval;
  2112. X    goto yyloop;
  2113. Xyyoverflow:
  2114. X    yyerror("yacc stack overflow");
  2115. Xyyabort:
  2116. X    return (1);
  2117. Xyyaccept:
  2118. X    return (0);
  2119. X}
  2120. END_OF_FILE
  2121. if test 6307 -ne `wc -c <'test/error.tab.c'`; then
  2122.     echo shar: \"'test/error.tab.c'\" unpacked with wrong size!
  2123. fi
  2124. # end of 'test/error.tab.c'
  2125. fi
  2126. if test -f 'test/error.tab.h' -a "${1}" != "-c" ; then 
  2127.   echo shar: Will not clobber existing file \"'test/error.tab.h'\"
  2128. else
  2129. echo shar: Extracting \"'test/error.tab.h'\" \(0 characters\)
  2130. sed "s/^X//" >'test/error.tab.h' <<'END_OF_FILE'
  2131. END_OF_FILE
  2132. if test 0 -ne `wc -c <'test/error.tab.h'`; then
  2133.     echo shar: \"'test/error.tab.h'\" unpacked with wrong size!
  2134. fi
  2135. # end of 'test/error.tab.h'
  2136. fi
  2137. if test -f 'test/error.y' -a "${1}" != "-c" ; then 
  2138.   echo shar: Will not clobber existing file \"'test/error.y'\"
  2139. else
  2140. echo shar: Extracting \"'test/error.y'\" \(117 characters\)
  2141. sed "s/^X//" >'test/error.y' <<'END_OF_FILE'
  2142. X%%
  2143. XS: error
  2144. X%%
  2145. Xmain(){printf("yyparse() = %d\n",yyparse());}
  2146. Xyylex(){return-1;}
  2147. Xyyerror(s)char*s;{printf("%s\n",s);}
  2148. END_OF_FILE
  2149. if test 117 -ne `wc -c <'test/error.y'`; then
  2150.     echo shar: \"'test/error.y'\" unpacked with wrong size!
  2151. fi
  2152. # end of 'test/error.y'
  2153. fi
  2154. if test -f 'test/ftp.tab.h' -a "${1}" != "-c" ; then 
  2155.   echo shar: Will not clobber existing file \"'test/ftp.tab.h'\"
  2156. else
  2157. echo shar: Extracting \"'test/ftp.tab.h'\" \(1038 characters\)
  2158. sed "s/^X//" >'test/ftp.tab.h' <<'END_OF_FILE'
  2159. X#define A 257
  2160. X#define B 258
  2161. X#define C 259
  2162. X#define E 260
  2163. X#define F 261
  2164. X#define I 262
  2165. X#define L 263
  2166. X#define N 264
  2167. X#define P 265
  2168. X#define R 266
  2169. X#define S 267
  2170. X#define T 268
  2171. X#define SP 269
  2172. X#define CRLF 270
  2173. X#define COMMA 271
  2174. X#define STRING 272
  2175. X#define NUMBER 273
  2176. X#define USER 274
  2177. X#define PASS 275
  2178. X#define ACCT 276
  2179. X#define REIN 277
  2180. X#define QUIT 278
  2181. X#define PORT 279
  2182. X#define PASV 280
  2183. X#define TYPE 281
  2184. X#define STRU 282
  2185. X#define MODE 283
  2186. X#define RETR 284
  2187. X#define STOR 285
  2188. X#define APPE 286
  2189. X#define MLFL 287
  2190. X#define MAIL 288
  2191. X#define MSND 289
  2192. X#define MSOM 290
  2193. X#define MSAM 291
  2194. X#define MRSQ 292
  2195. X#define MRCP 293
  2196. X#define ALLO 294
  2197. X#define REST 295
  2198. X#define RNFR 296
  2199. X#define RNTO 297
  2200. X#define ABOR 298
  2201. X#define DELE 299
  2202. X#define CWD 300
  2203. X#define LIST 301
  2204. X#define NLST 302
  2205. X#define SITE 303
  2206. X#define STAT 304
  2207. X#define HELP 305
  2208. X#define NOOP 306
  2209. X#define MKD 307
  2210. X#define RMD 308
  2211. X#define PWD 309
  2212. X#define CDUP 310
  2213. X#define STOU 311
  2214. X#define SMNT 312
  2215. X#define SYST 313
  2216. X#define SIZE 314
  2217. X#define MDTM 315
  2218. X#define UMASK 316
  2219. X#define IDLE 317
  2220. X#define CHMOD 318
  2221. X#define LEXERR 319
  2222. END_OF_FILE
  2223. if test 1038 -ne `wc -c <'test/ftp.tab.h'`; then
  2224.     echo shar: \"'test/ftp.tab.h'\" unpacked with wrong size!
  2225. fi
  2226. # end of 'test/ftp.tab.h'
  2227. fi
  2228. if test -f 'verbose.c' -a "${1}" != "-c" ; then 
  2229.   echo shar: Will not clobber existing file \"'verbose.c'\"
  2230. else
  2231. echo shar: Extracting \"'verbose.c'\" \(6579 characters\)
  2232. sed "s/^X//" >'verbose.c' <<'END_OF_FILE'
  2233. X#include "defs.h"
  2234. X
  2235. X
  2236. Xstatic short *null_rules;
  2237. X
  2238. Xverbose()
  2239. X{
  2240. X    register int i;
  2241. X
  2242. X    if (!vflag) return;
  2243. X
  2244. X    null_rules = (short *) MALLOC(nrules*sizeof(short));
  2245. X    if (null_rules == 0) no_space();
  2246. X    fprintf(verbose_file, "\f\n");
  2247. X    for (i = 0; i < nstates; i++)
  2248. X    print_state(i);
  2249. X    FREE(null_rules);
  2250. X
  2251. X    if (nunused)
  2252. X    log_unused();
  2253. X    if (SRtotal || RRtotal)
  2254. X    log_conflicts();
  2255. X
  2256. X    fprintf(verbose_file, "\n\n%d terminals, %d nonterminals\n", ntokens,
  2257. X        nvars);
  2258. X    fprintf(verbose_file, "%d grammar rules, %d states\n", nrules - 2, nstates);
  2259. X}
  2260. X
  2261. X
  2262. Xlog_unused()
  2263. X{
  2264. X    register int i;
  2265. X    register short *p;
  2266. X
  2267. X    fprintf(verbose_file, "\n\nRules never reduced:\n");
  2268. X    for (i = 3; i < nrules; ++i)
  2269. X    {
  2270. X    if (!rules_used[i])
  2271. X    {
  2272. X        fprintf(verbose_file, "\t%s :", symbol_name[rlhs[i]]);
  2273. X        for (p = ritem + rrhs[i]; *p >= 0; ++p)
  2274. X        fprintf(verbose_file, " %s", symbol_name[*p]);
  2275. X        fprintf(verbose_file, "  (%d)\n", i - 2);
  2276. X    }
  2277. X    }
  2278. X}
  2279. X
  2280. X
  2281. Xlog_conflicts()
  2282. X{
  2283. X    register int i;
  2284. X
  2285. X    fprintf(verbose_file, "\n\n");
  2286. X    for (i = 0; i < nstates; i++)
  2287. X    {
  2288. X    if (SRconflicts[i] || RRconflicts[i])
  2289. X    {
  2290. X        fprintf(verbose_file, "State %d contains ", i);
  2291. X        if (SRconflicts[i] == 1)
  2292. X        fprintf(verbose_file, "1 shift/reduce conflict");
  2293. X        else if (SRconflicts[i] > 1)
  2294. X        fprintf(verbose_file, "%d shift/reduce conflicts",
  2295. X            SRconflicts[i]);
  2296. X        if (SRconflicts[i] && RRconflicts[i])
  2297. X        fprintf(verbose_file, ", ");
  2298. X        if (RRconflicts[i] == 1)
  2299. X        fprintf(verbose_file, "1 reduce/reduce conflict");
  2300. X        else if (RRconflicts[i] > 1)
  2301. X        fprintf(verbose_file, "%d reduce/reduce conflicts",
  2302. X            RRconflicts[i]);
  2303. X        fprintf(verbose_file, ".\n");
  2304. X    }
  2305. X    }
  2306. X}
  2307. X
  2308. X
  2309. Xprint_state(state)
  2310. Xint state;
  2311. X{
  2312. X    if (state)
  2313. X    fprintf(verbose_file, "\n\n");
  2314. X    if (SRconflicts[state] || RRconflicts[state])
  2315. X    print_conflicts(state);
  2316. X    fprintf(verbose_file, "state %d\n", state);
  2317. X    print_core(state);
  2318. X    print_nulls(state);
  2319. X    print_actions(state);
  2320. X}
  2321. X
  2322. X
  2323. Xprint_conflicts(state)
  2324. Xint state;
  2325. X{
  2326. X    register int symbol;
  2327. X    register action *p, *q, *r;
  2328. X
  2329. X    for (p = parser[state]; p; p = q->next)
  2330. X    {
  2331. X    q = p;
  2332. X    if (p->action_code == ERROR || p->suppressed == 2)
  2333. X        continue;
  2334. X
  2335. X    symbol = p->symbol;
  2336. X    while (q->next && q->next->symbol == symbol)
  2337. X        q = q->next;
  2338. X    if (state == final_state && symbol == 0)
  2339. X    {
  2340. X        r = p;
  2341. X        for (;;)
  2342. X        {
  2343. X        fprintf(verbose_file, "%d: shift/reduce conflict \
  2344. X(accept, reduce %d) on $end\n", state, r->number - 2);
  2345. X        if (r == q) break;
  2346. X        r = r->next;
  2347. X        }
  2348. X    }
  2349. X    else if (p != q)
  2350. X    {
  2351. X        r = p->next;
  2352. X        if (p->action_code == SHIFT)
  2353. X        {
  2354. X        for (;;)
  2355. X        {
  2356. X            if (r->action_code == REDUCE && p->suppressed != 2)
  2357. X            fprintf(verbose_file, "%d: shift/reduce conflict \
  2358. X(shift %d, reduce %d) on %s\n", state, p->number, r->number - 2,
  2359. X                symbol_name[symbol]);
  2360. X            if (r == q) break;
  2361. X            r = r->next;
  2362. X        }
  2363. X        }
  2364. X        else
  2365. X        {
  2366. X        for (;;)
  2367. X        {
  2368. X            if (r->action_code == REDUCE && p->suppressed != 2)
  2369. X            fprintf(verbose_file, "%d: reduce/reduce conflict \
  2370. X(reduce %d, reduce %d) on %s\n", state, p->number - 2, r->number - 2,
  2371. X                symbol_name[symbol]);
  2372. X            if (r == q) break;
  2373. X            r = r->next;
  2374. X        }
  2375. X        }
  2376. X    }
  2377. X    }
  2378. X}
  2379. X
  2380. X
  2381. Xprint_core(state)
  2382. Xint state;
  2383. X{
  2384. X    register int i;
  2385. X    register int k;
  2386. X    register int rule;
  2387. X    register core *statep;
  2388. X    register short *sp;
  2389. X    register short *sp1;
  2390. X
  2391. X    statep = state_table[state];
  2392. X    k = statep->nitems;
  2393. X
  2394. X    for (i = 0; i < k; i++)
  2395. X    {
  2396. X    sp1 = sp = ritem + statep->items[i];
  2397. X
  2398. X    while (*sp >= 0) ++sp;
  2399. X    rule = -(*sp);
  2400. X    fprintf(verbose_file, "\t%s : ", symbol_name[rlhs[rule]]);
  2401. X
  2402. X        for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
  2403. X        fprintf(verbose_file, "%s ", symbol_name[*sp]);
  2404. X
  2405. X    putc('.', verbose_file);
  2406. X
  2407. X    while (*sp >= 0)
  2408. X    {
  2409. X        fprintf(verbose_file, " %s", symbol_name[*sp]);
  2410. X        sp++;
  2411. X    }
  2412. X    fprintf(verbose_file, "  (%d)\n", -2 - *sp);
  2413. X    }
  2414. X}
  2415. X
  2416. X
  2417. Xprint_nulls(state)
  2418. Xint state;
  2419. X{
  2420. X    register action *p;
  2421. X    register int i, j, k, nnulls;
  2422. X
  2423. X    nnulls = 0;
  2424. X    for (p = parser[state]; p; p = p->next)
  2425. X    {
  2426. X    if (p->action_code == REDUCE &&
  2427. X        (p->suppressed == 0 || p->suppressed == 1))
  2428. X    {
  2429. X        i = p->number;
  2430. X        if (rrhs[i] + 1 == rrhs[i+1])
  2431. X        {
  2432. X        for (j = 0; j < nnulls && i > null_rules[j]; ++j)
  2433. X            continue;
  2434. X
  2435. X        if (j == nnulls)
  2436. X        {
  2437. X            ++nnulls;
  2438. X            null_rules[j] = i;
  2439. X        }
  2440. X        else if (i != null_rules[j])
  2441. X        {
  2442. X            ++nnulls;
  2443. X            for (k = nnulls - 1; k > j; --k)
  2444. X            null_rules[k] = null_rules[k-1];
  2445. X            null_rules[j] = i;
  2446. X        }
  2447. X        }
  2448. X    }
  2449. X    }
  2450. X
  2451. X    for (i = 0; i < nnulls; ++i)
  2452. X    {
  2453. X    j = null_rules[i];
  2454. X    fprintf(verbose_file, "\t%s : .  (%d)\n", symbol_name[rlhs[j]],
  2455. X        j - 2);
  2456. X    }
  2457. X    fprintf(verbose_file, "\n");
  2458. X}
  2459. X
  2460. X
  2461. Xprint_actions(stateno)
  2462. Xint stateno;
  2463. X{
  2464. X    register action *p;
  2465. X    register shifts *sp;
  2466. X    register int as;
  2467. X
  2468. X    if (stateno == final_state)
  2469. X    fprintf(verbose_file, "\t$end  accept\n");
  2470. X
  2471. X    p = parser[stateno];
  2472. X    if (p)
  2473. X    {
  2474. X    print_shifts(p);
  2475. X    print_reductions(p, defred[stateno]);
  2476. X    }
  2477. X
  2478. X    sp = shift_table[stateno];
  2479. X    if (sp && sp->nshifts > 0)
  2480. X    {
  2481. X    as = accessing_symbol[sp->shift[sp->nshifts - 1]];
  2482. X    if (ISVAR(as))
  2483. X        print_gotos(stateno);
  2484. X    }
  2485. X}
  2486. X
  2487. X
  2488. Xprint_shifts(p)
  2489. Xregister action *p;
  2490. X{
  2491. X    register int count;
  2492. X    register action *q;
  2493. X
  2494. X    count = 0;
  2495. X    for (q = p; q; q = q->next)
  2496. X    {
  2497. X    if (q->suppressed < 2 && q->action_code == SHIFT)
  2498. X        ++count;
  2499. X    }
  2500. X
  2501. X    if (count > 0)
  2502. X    {
  2503. X    for (; p; p = p->next)
  2504. X    {
  2505. X        if (p->action_code == SHIFT && p->suppressed == 0)
  2506. X        fprintf(verbose_file, "\t%s  shift %d\n",
  2507. X                symbol_name[p->symbol], p->number);
  2508. X    }
  2509. X    }
  2510. X}
  2511. X
  2512. X
  2513. Xprint_reductions(p, defred)
  2514. Xregister action *p;
  2515. Xregister int defred;
  2516. X{
  2517. X    register int k, anyreds;
  2518. X    register action *q;
  2519. X
  2520. X    anyreds = 0;
  2521. X    for (q = p; q ; q = q->next)
  2522. X    {
  2523. X    if (q->action_code == REDUCE && q->suppressed < 2)
  2524. X    {
  2525. X        anyreds = 1;
  2526. X        break;
  2527. X    }
  2528. X    }
  2529. X
  2530. X    if (anyreds == 0)
  2531. X    fprintf(verbose_file, "\t.  error\n");
  2532. X    else
  2533. X    {
  2534. X    for (; p; p = p->next)
  2535. X    {
  2536. X        if (p->action_code == REDUCE && p->number != defred)
  2537. X        {
  2538. X        k = p->number - 2;
  2539. X        if (p->suppressed == 0)
  2540. X            fprintf(verbose_file, "\t%s  reduce %d\n",
  2541. X                symbol_name[p->symbol], k);
  2542. X        }
  2543. X    }
  2544. X
  2545. X        if (defred > 0)
  2546. X        fprintf(verbose_file, "\t.  reduce %d\n", defred - 2);
  2547. X    }
  2548. X}
  2549. X
  2550. X
  2551. Xprint_gotos(stateno)
  2552. Xint stateno;
  2553. X{
  2554. X    register int i, k;
  2555. X    register int as;
  2556. X    register short *to_state;
  2557. X    register shifts *sp;
  2558. X
  2559. X    putc('\n', verbose_file);
  2560. X    sp = shift_table[stateno];
  2561. X    to_state = sp->shift;
  2562. X    for (i = 0; i < sp->nshifts; ++i)
  2563. X    {
  2564. X    k = to_state[i];
  2565. X    as = accessing_symbol[k];
  2566. X    if (ISVAR(as))
  2567. X        fprintf(verbose_file, "\t%s  goto %d\n", symbol_name[as], k);
  2568. X    }
  2569. X}
  2570. END_OF_FILE
  2571. if test 6579 -ne `wc -c <'verbose.c'`; then
  2572.     echo shar: \"'verbose.c'\" unpacked with wrong size!
  2573. fi
  2574. # end of 'verbose.c'
  2575. fi
  2576. if test -f 'warshall.c' -a "${1}" != "-c" ; then 
  2577.   echo shar: Will not clobber existing file \"'warshall.c'\"
  2578. else
  2579. echo shar: Extracting \"'warshall.c'\" \(1205 characters\)
  2580. sed "s/^X//" >'warshall.c' <<'END_OF_FILE'
  2581. X#include "defs.h"
  2582. X
  2583. Xtransitive_closure(R, n)
  2584. Xunsigned *R;
  2585. Xint n;
  2586. X{
  2587. X    register int rowsize;
  2588. X    register unsigned mask;
  2589. X    register unsigned *rowj;
  2590. X    register unsigned *rp;
  2591. X    register unsigned *rend;
  2592. X    register unsigned *ccol;
  2593. X    register unsigned *relend;
  2594. X    register unsigned *cword;
  2595. X    register unsigned *rowi;
  2596. X
  2597. X    rowsize = WORDSIZE(n);
  2598. X    relend = R + n*rowsize;
  2599. X
  2600. X    cword = R;
  2601. X    mask = 1;
  2602. X    rowi = R;
  2603. X    while (rowi < relend)
  2604. X    {
  2605. X    ccol = cword;
  2606. X    rowj = R;
  2607. X
  2608. X    while (rowj < relend)
  2609. X    {
  2610. X        if (*ccol & mask)
  2611. X        {
  2612. X        rp = rowi;
  2613. X        rend = rowj + rowsize;
  2614. X        while (rowj < rend)
  2615. X            *rowj++ |= *rp++;
  2616. X        }
  2617. X        else
  2618. X        {
  2619. X        rowj += rowsize;
  2620. X        }
  2621. X
  2622. X        ccol += rowsize;
  2623. X    }
  2624. X
  2625. X    mask <<= 1;
  2626. X    if (mask == 0)
  2627. X    {
  2628. X        mask = 1;
  2629. X        cword++;
  2630. X    }
  2631. X
  2632. X    rowi += rowsize;
  2633. X    }
  2634. X}
  2635. X
  2636. Xreflexive_transitive_closure(R, n)
  2637. Xunsigned *R;
  2638. Xint n;
  2639. X{
  2640. X    register int rowsize;
  2641. X    register unsigned mask;
  2642. X    register unsigned *rp;
  2643. X    register unsigned *relend;
  2644. X
  2645. X    transitive_closure(R, n);
  2646. X
  2647. X    rowsize = WORDSIZE(n);
  2648. X    relend = R + n*rowsize;
  2649. X
  2650. X    mask = 1;
  2651. X    rp = R;
  2652. X    while (rp < relend)
  2653. X    {
  2654. X    *rp |= mask;
  2655. X    mask <<= 1;
  2656. X    if (mask == 0)
  2657. X    {
  2658. X        mask = 1;
  2659. X        rp++;
  2660. X    }
  2661. X
  2662. X    rp += rowsize;
  2663. X    }
  2664. X}
  2665. END_OF_FILE
  2666. if test 1205 -ne `wc -c <'warshall.c'`; then
  2667.     echo shar: \"'warshall.c'\" unpacked with wrong size!
  2668. fi
  2669. # end of 'warshall.c'
  2670. fi
  2671. echo shar: End of archive 1 \(of 5\).
  2672. cp /dev/null ark1isdone
  2673. MISSING=""
  2674. for I in 1 2 3 4 5 ; do
  2675.     if test ! -f ark${I}isdone ; then
  2676.     MISSING="${MISSING} ${I}"
  2677.     fi
  2678. done
  2679. if test "${MISSING}" = "" ; then
  2680.     echo You have unpacked all 5 archives.
  2681.     rm -f ark[1-9]isdone
  2682. else
  2683.     echo You still need to unpack the following archives:
  2684.     echo "        " ${MISSING}
  2685. fi
  2686. ##  End of shell archive.
  2687. exit 0
  2688.